<?php

/*
	Class: Cts_Request

	About: Author
		Jaybill McCarthy

	About: License
		<http://communit.as/docs/license>
*/
class Cts_Request {

	/* Group: Constructors */

	/*
		Constructor: __construct

		Arguments:
			request - An HTTP Request object.

		Returns:
			void
	*/
 	function __construct($request){
 		$params = $request->getParams();
 		foreach ($params as $name => $param) {
			if(!is_array($param)){
 		        $param =  trim($param);
    			if (strlen($param) == 0) {
     				$this->$name = null;
    			} else {
     				$this->$name = $param;
    			}
			} else {
     				$this->$name = $param;
			} 
					    
 		    
 		}
 	}

	/* Group: Instance Methods */

	/*
		Function: stripTags

		Arguments:
			properties - TBD

		Returns:
			void
	*/
 	function stripTags($properties) {
 		$tag_filter = new Zend_Filter_StripTags();
 		foreach ($properties as $property) {
 			if($this->has($property)){
 				$this->$property = $tag_filter->filter($this->$property);
 			}
 		}
 	}

	/*
		Function: has
			TBD

		Arguments:
			var - TBD

		Returns:
			boolean
	*/
 	function has($var) {
 		if (array_key_exists($var, get_object_vars($this))) {
 			return true;
 		} else {
 			return false;
 		}
 	}
 	
	/*
		Function: checkbox
			forces a boolean for a checkbox

		Arguments:
			var - checkbox value to evaluate
			
	*/
 	  function checkbox($var){
 	    $out = false;
 	    if($this->has($var)){
 	      if((boolean)$var){
 	        $out = true;
 	      }  
 	    } 	    
 	    return $out;
 	  }
 	
}
